﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using EmoneyWeiXinEntity;
using EmoneyWeiXinCommon;
namespace EmoneyWeiXinDAL
{
    public class NewsReportfbDal
    {
        public NewsReportEntity getNewsReportOne(string id)
        {
            string sql = "select * from newsReport with(nolock) where id=" + id;
            return SQLHelper.GetDataByColumns<NewsReportEntity>(Config.EmoneyWeiXin, sql, null);
        }

        public static List<NewsReportfbEntity> getNewsReportfbList(int pindex, int psize, out int total, string memutype, string pubdate1, string pubdate2, int userId)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@pindex",pindex),
            new SqlParameter("@psize", psize),
            new SqlParameter("@total",0),
            new SqlParameter("@memutype",memutype),
            new SqlParameter("@pubdate1",pubdate1),
            new SqlParameter("@pubdate2",pubdate2),
            new SqlParameter("@userId",userId),
            };
            parameters[2].Direction = ParameterDirection.Output;
            List<NewsReportfbEntity> result = SQLHelper.GetProcedureDataByColumnsLst<NewsReportfbEntity>(Config.EmoneyWeiXin, "sp_newsReportfb_Select", parameters);
            total = Convert.ToInt32(parameters[2].Value);
            return result;
        }
        public static List<NewsReportfbEntity> getNewsReportfbListByID(int id)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@ID", id)
            };
            List<NewsReportfbEntity> result = SQLHelper.GetProcedureDataByColumnsLst<NewsReportfbEntity>(Config.EmoneyWeiXin, "sp_newsReportfb_SelectByID", parameters);
            return result;
        }
        public static int UpdateNewsReportfb(NewsReportfbEntity obj)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@ID" , obj.ID),				
            new SqlParameter("@MemuType" , obj.MemuType),				
            new SqlParameter("@title", obj.title),				
            new SqlParameter("@Author" , obj.Author),				
            new SqlParameter("@pubDate", obj.pubDate),				
            new SqlParameter("@Stock",obj.Stock),				
            new SqlParameter("@keyword", obj.keyword),				
            new SqlParameter("@Summary", obj.Summary),				
            new SqlParameter("@Content", obj.Content),				
            new SqlParameter("@PubStatus", obj.PubStatus),				
            new SqlParameter("@Step", obj.Step),				
            new SqlParameter("@OutsideUrl", obj.OutsideUrl),				
            new SqlParameter("@ImageUrl", obj.ImageUrl),				
            new SqlParameter("@Nature", obj.Nature),				
            new SqlParameter("@isupdate", obj.isupdate),				
            new SqlParameter("@isvalid", obj.isvalid),				
            new SqlParameter("@createtime", obj.createtime),				
            new SqlParameter("@updatetime", obj.updatetime),				
            new SqlParameter("@remark", obj.remark),				
            new SqlParameter("@newguid", obj.newguid),				
            new SqlParameter("@PubMethod", obj.PubMethod),				
            new SqlParameter("@source", obj.source)	
            };
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_newsReportfb_Update", parameters);
            return result;
        }
        public static int UpdateValidNewsReportfb(int id, int isvalid)
        {
            SqlParameter[] parameters = new SqlParameter[] {  
            new SqlParameter("@ID", id),
             new SqlParameter("@isvalid", isvalid)};
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_newsReportfb_Delete", parameters);
            return result;
        }
    }
}
